package com.test.map.Users;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;

public class Client {
    private String name;
    private String place;
    private String client_place;
    private String distance_client;
    private String distance;
    private String order_id;
    private String phone;
    private String price;
    private String id;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }
    public String getPlace() {
        return place;
    }

    public void setPlace(String place) {
        this.place = place;
    }

    public String getClient_place() {
        return client_place;
    }

    public void setClient_place(String client_place) {
        this.client_place = client_place;
    }

    public String getDistance_client() {
        return distance_client;
    }

    public void setDistance_client(String distance_client) {
        this.distance_client = distance_client;
    }

    public String getDistance() {
        return distance;
    }

    public void setDistance(String distance) {
        this.distance = distance;
    }

    public String getOrder_id() {
        return order_id;
    }

    public void setOrder_id(String order_id) {
        this.order_id = order_id;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public ArrayList<Client> parsing(JSONArray jsonoArray){
        ArrayList<Client> ClientList=new ArrayList<Client>();

            try {
                for(int i=0;i<jsonoArray.length();i++) {
                    JSONObject jsonObject=(JSONObject)jsonoArray.get(i);
                    Client client = new Client();
                    client.setName(jsonObject.getString("name"));
                    client.setClient_place(jsonObject.getString("client_place"));
                    client.setDistance(jsonObject.getString("distance"));
                    client.setDistance_client(jsonObject.getString("distance_client"));
                    client.setOrder_id(jsonObject.getString("order_id"));
                    client.setPhone(jsonObject.getString("phone"));
                    client.setPlace(jsonObject.getString("place"));
                    client.setPrice(jsonObject.getString("price"));
                    client.id = jsonObject.getString("order_id");
                    ClientList.add(client);
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
        return ClientList;
    }

}
